package com.control.mbtc.fragments.adapter;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;

import com.zzyd.common.app.AppFragment;

import java.util.List;

/**
 * @author wjunjie
 * @version 1.0
 * @E-mail wang_junjie007@163.com
 * @company ZZYD
 * @createTime 2018/7/27 14:10
 * @类注释: ViewpagerAdapter
 */
public class ViewpagerAdapter extends FragmentStatePagerAdapter {
    private List<AppFragment> fragments;
    private String[] title;

    public ViewpagerAdapter(FragmentManager fm) {
        super(fm);
    }

    public ViewpagerAdapter(FragmentManager fm, List<AppFragment> fragments, String[] title) {
        super(fm);
        this.fragments = fragments;
        this.title = title;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments == null ? 0 : fragments.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return title[position];
    }
}
